package com.learning.servlet3x.context;

import javax.servlet.Filter;
import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.HandlesTypes;
import javax.servlet.http.HttpServlet;
import java.util.Set;

/**
 * ClassName: WebInitializer
 * Description: Web  初始化（Spring 就有自定义的 SpringServletContainerInitializer ）
 * 注解 @HandlesTypes 注解来指定希望被处理的类，过滤掉不希望给 onStartup() 处理的类
 * <p>
 * Date: 2014/12/06  22:11 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
@HandlesTypes({HttpServlet.class, Filter.class})
public class WebInitializer implements ServletContainerInitializer {
    @Override
    public void onStartup(Set<Class<?>> classes, ServletContext ctx) throws ServletException {

        System.out.println("ServletContainerInitializer 实现初始化");

        for (Class c : classes) {
            System.out.println(c.getName());
        }
    }
}
